package com.muyan.countdownlatch;

class Athlete implements Runnable {
	Timer timer;
	String athleteName;

	public Athlete(Timer timer, String athleteName) {
		this.timer = timer;
		this.athleteName = athleteName;
	}

	public void run() {
		try {
			System.out.println(athleteName + " start running");
			long duration = (long) (Math.random() * 10);
			Thread.sleep(duration * 1000);
			timer.recordResult(athleteName);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}